<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:rich="http://richfaces.org/rich"
                template="layout/template.xhtml">
                       
<ui:define name="body">
    
    <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>
    
    <h:form id="korisnikSearch" styleClass="edit">
    
        <rich:simpleTogglePanel label="Parametri za pretragu:" switchType="ajax">
 
            <s:decorate template="layout/display.xhtml">
                <ui:define name="label">Ime</ui:define>
                <h:inputText id="ime" value="#{korisnikList.korisnik.ime}"/>
            </s:decorate>
            
            <s:decorate template="layout/display.xhtml">
                <ui:define name="label">Prezime</ui:define>
                <h:inputText id="prezime" value="#{korisnikList.korisnik.prezime}"/>
            </s:decorate>
            
            <s:decorate template="layout/display.xhtml">
                <ui:define name="label">Adresa</ui:define>
                <h:inputText id="adresa" value="#{korisnikList.korisnik.adresa}"/>
            </s:decorate>

            <s:decorate template="layout/display.xhtml">
                <ui:define name="label">Mesto</ui:define>
                <h:inputText id="mesto" value="#{korisnikList.korisnik.mesto}"/>
            </s:decorate>            

            <s:decorate template="layout/display.xhtml">
                <ui:define name="label">Drzava</ui:define>
                <h:inputText id="drzava" value="#{korisnikList.korisnik.drzava}"/>
            </s:decorate>

            <s:decorate template="layout/display.xhtml">
                <ui:define name="label">Password</ui:define>
                <h:inputText id="password" value="#{korisnikList.korisnik.password}"/>
            </s:decorate>

            <s:decorate template="layout/display.xhtml">
                <ui:define name="label">Username</ui:define>
                <h:inputText id="username" value="#{korisnikList.korisnik.username}"/>
            </s:decorate>

        
        </rich:simpleTogglePanel>
        
        <div class="actionButtons">
            <h:commandButton id="search" value="Pronadji" action="/KorisnikList.xhtml"/>
        </div>
        
    </h:form>
    
    <rich:panel>
        <f:facet name="header">Rezultati pretrage:</f:facet>
    <div class="results" id="korisnikList">

    <h:outputText value="Ne postoji trazeni korisnik." 
               rendered="#{empty korisnikList.resultList}"/>
               
    <rich:dataTable id="korisnikList" 
                var="korisnik"
              value="#{korisnikList.resultList}" 
           rendered="#{not empty korisnikList.resultList}">


        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="Ime #{korisnikList.order=='ime asc' ? messages.down : ( korisnikList.order=='ime desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{korisnikList.order=='ime asc' ? 'ime desc' : 'ime asc'}"/>
                </s:link>
            </f:facet>
            #{korisnik.ime}
        </h:column>
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="Prezime #{korisnikList.order=='prezime asc' ? messages.down : ( korisnikList.order=='prezime desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{korisnikList.order=='prezime asc' ? 'prezime desc' : 'prezime asc'}"/>
                </s:link>
            </f:facet>
            #{korisnik.prezime}
        </h:column>        
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="Jmbg #{korisnikList.order=='jmbg asc' ? messages.down : ( korisnikList.order=='jmbg desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{korisnikList.order=='jmbg asc' ? 'jmbg desc' : 'jmbg asc'}"/>
                </s:link>
            </f:facet>
            #{korisnik.jmbg}
        </h:column>
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="Adresa #{korisnikList.order=='adresa asc' ? messages.down : ( korisnikList.order=='adresa desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{korisnikList.order=='adresa asc' ? 'adresa desc' : 'adresa asc'}"/>
                </s:link>
            </f:facet>
            #{korisnik.adresa}
        </h:column>
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="Ptt #{korisnikList.order=='ptt asc' ? messages.down : ( korisnikList.order=='ptt desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{korisnikList.order=='ptt asc' ? 'ptt desc' : 'ptt asc'}"/>
                </s:link>
            </f:facet>
            #{korisnik.ptt}
        </h:column>        
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="Mesto #{korisnikList.order=='mesto asc' ? messages.down : ( korisnikList.order=='mesto desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{korisnikList.order=='mesto asc' ? 'mesto desc' : 'mesto asc'}"/>
                </s:link>
            </f:facet>
            #{korisnik.mesto}
        </h:column>        
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="Drzava #{korisnikList.order=='drzava asc' ? messages.down : ( korisnikList.order=='drzava desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{korisnikList.order=='drzava asc' ? 'drzava desc' : 'drzava asc'}"/>
                </s:link>
            </f:facet>
            #{korisnik.drzava}
        </h:column>
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="Username #{korisnikList.order=='username asc' ? messages.down : ( korisnikList.order=='username desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{korisnikList.order=='username asc' ? 'username desc' : 'username asc'}"/>
                </s:link>
            </f:facet>
            #{korisnik.username}
        </h:column>
        <h:column>
            <f:facet name="header"> Akcije </f:facet>
            <s:link view="/#{empty from ? 'Korisnik' : from}.xhtml" 
                   value="Izaberi" 
                      id="korisnik">
                <f:param name="korisnikId" 
                        value="#{korisnik.id}"/>
            </s:link>
        </h:column>
    </rich:dataTable>

    </div>
    </rich:panel>
    
    <div class="tableControl">
      
        <s:link view="/KorisnikList.xhtml" 
            rendered="#{korisnikList.previousExists}" 
               value="#{messages.left}#{messages.left} "
                  id="firstPage">
          <f:param name="firstResult" value="0"/>
        </s:link>
        
        <s:link view="/KorisnikList.xhtml" 
            rendered="#{korisnikList.previousExists}" 
               value="#{messages.left} "
                  id="previousPage">
            <f:param name="firstResult" 
                    value="#{korisnikList.previousFirstResult}"/>
        </s:link>
        
        <s:link view="/KorisnikList.xhtml" 
            rendered="#{korisnikList.nextExists}" 
               value=" #{messages.right}"
                  id="nextPage">
            <f:param name="firstResult" 
                    value="#{korisnikList.nextFirstResult}"/>
        </s:link>
        
        <s:link view="/KorisnikList.xhtml" 
            rendered="#{korisnikList.nextExists}" 
               value=" #{messages.right}#{messages.right}"
                  id="lastPage">
            <f:param name="firstResult" 
                    value="#{korisnikList.lastFirstResult}"/>
        </s:link>
        
    </div>
    
    <s:div styleClass="actionButtons" rendered="#{empty from}">
        <s:button view="/KorisnikEdit.xhtml"
                    id="create" 
                 value="Dodaj korisnika">
            <f:param name="korisnikId"/>
        </s:button>
    </s:div>
    
</ui:define>

</ui:composition>

